package com.seeyon.apps.gkcwplugin.manager.impl;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.TimeZone;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import com.aspose.imaging.internal.a.p;
import com.aspose.imaging.internal.bk.bo;
import com.seeyon.apps.edoc.event.EdocTakeBackEvent;
import com.seeyon.apps.gkcwplugin.dao.DealDataDao;
import com.seeyon.apps.gkcwplugin.manager.SyncZDManager;
import com.seeyon.apps.gkcwplugin.po.BankAccounts;
import com.seeyon.apps.gkcwplugin.po.ContactUnit;
import com.seeyon.apps.gkcwplugin.po.DepartmentPO;
import com.seeyon.apps.gkcwplugin.po.DeptToSubject;
import com.seeyon.apps.gkcwplugin.po.Personnel;
import com.seeyon.apps.gkcwplugin.po.SubjectPO;
import com.seeyon.apps.gkcwplugin.util.DateConvertUtil;
import com.seeyon.apps.gkcwplugin.util.SoapsendUtil;
import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.util.DateUtil;

public class SyncZDManagerImpl implements SyncZDManager{
	private static final Log logger=LogFactory.getLog(SyncZDManagerImpl.class);
	private DealDataDao dealDataDao=(DealDataDao)AppContext.getBean("dealDataDao");
	//调用系统登录接口
	public String systemInOut() {
		logger.info("-----------------------调用系统登录接口");
		String systemUrl=AppContext.getSystemProperty("gkcwplugin.systemUrl");
		//获取xml参数
		String systemXml=getSystemXml();
		String res=new SoapsendUtil().postSoap(systemXml, systemUrl);
		try {
			//字符串转xml
			Document doc=DocumentHelper.parseText(res);
			//获取根节点
			Element root=doc.getRootElement();
			logger.info("-----------------系统登录接口-根节点："+root.getName());
			Iterator iterator=root.element("Body").element("LoginResponse").elementIterator("LoginResult");
			while(iterator.hasNext()) {
				Element element=(Element) iterator.next();
				String result=element.elementTextTrim("Result");
				logger.info("----------------------系统登录接口-result："+result);
				if ("true".equals(result)) {
					String message=element.elementTextTrim("Message");
					logger.info("----------------------系统登录接口-sessionid："+message);
					return message;
				}
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	//同步往来单位
	@Override
	public void syncContactUnit(String sessionId,boolean dingshi) {
		logger.info("-------------------------处理同步往来单位方法");
		String contactUnitUrl=AppContext.getSystemProperty("gkcwplugin.wldwUrl");
		//获取计数接口xml参数
		String countxml=getNumXml(sessionId,dingshi);
		logger.info("------------------------计数接口xml参数："+countxml);
		//----1调用计数服务接口
		String res=new SoapsendUtil().postSoap(countxml, contactUnitUrl);
		//logger.info("------------------------计数接口返回数据："+res);
		//获取数据条数
		int count=getCount(res);
		if (count==0) {
			return;
		}
		int num=1000;
		int ammount=0;
		//循环次数
		if(count>1000) {
			ammount=count/num+1;
			logger.info("--------------次数："+ammount);
			if (count%num==0) {//总条数/每次查询条数（1000）余数为0，则减去1（上面逻辑默认+1次）
				ammount=ammount-1;
			}
		}else {
			ammount=1;
		}
		int startIndex=0;
		for (int i = 0; i < ammount; i++) {
			logger.info("---------------i="+i+",startIndex:"+startIndex);
			//获取往来单位查询xml
			String queryXml=getUnitQueryXml(sessionId, startIndex,dingshi);
			logger.info("------------------------查询接口xml参数："+queryXml);
			//-----2调用往来单位查询接口
			String dw=new SoapsendUtil().postSoap(queryXml, contactUnitUrl);
			//logger.info("------------------------查询接口返回数据："+dw);
			//定义集合，用于存放所有往来单位
			List<ContactUnit> contactUnitList=new ArrayList<ContactUnit>();
			//存放需更新的记录，定时获取字典数据时用
			List<ContactUnit> updateContactUnitList=new ArrayList<ContactUnit>();
			//处理接口返回数据
			contactUnitList=getContactUnitList(dw,contactUnitList,updateContactUnitList,dingshi);
			
			if (updateContactUnitList!=null&&updateContactUnitList.size()>0) {
				dealDataDao.updateContactUnitList(updateContactUnitList);
			}
			
			if (contactUnitList!=null&&contactUnitList.size()>0) {
				dealDataDao.saveContactUnitList(contactUnitList);
			}
			startIndex=startIndex+1000;//每次请求1000条
		}
		logger.info("---------------------往来单位处理完成");
		
	}
	//同步核算部门
	@Override
	public void syncDepartment(String sessionId,boolean dingshi) {
		logger.info("-------------------------处理核算部门方法");
		String bumenUrl=AppContext.getSystemProperty("gkcwplugin.bmzdUrl");
		//获取计数接口xml参数
		String countxml=getNumXml(sessionId,dingshi);
		logger.info("------------------------计数接口xml参数："+countxml);
		//----1调用计数服务接口
		String res=new SoapsendUtil().postSoap(countxml, bumenUrl);
		//logger.info("------------------------计数接口返回数据："+res);
		//获取数据条数
		int count=getCount(res);
		if (count==0) {
			return;
		}
		int num=500;
		int ammount=0;
		//循环次数
		if(count>500) {
			ammount=count/num+1;
			logger.info("--------------次数："+ammount);
			if (count%num==0) {
				ammount=ammount-1;
			}
		}else {
			ammount=1;
		}
		int startIndex=0;
		for(int i = 0; i < ammount; i++) {
			logger.info("---------------i="+i+",startIndex:"+startIndex);
			//获取核算部门查询xml
			String queryXml=getQueryXml(sessionId, startIndex,true,dingshi);
			logger.info("------------------------查询接口xml参数："+queryXml);
			//-----2调用核算部门查询接口
			String bm=new SoapsendUtil().postSoap(queryXml, bumenUrl);
			//定义集合，用于存放所有部门
			List<DepartmentPO> depList=new ArrayList<DepartmentPO>();
			//更新集合，定时任务用
			List<DepartmentPO> updateDeptList=new ArrayList<DepartmentPO>();
			//获取核算部门记录
			depList=getDeptList(bm, depList,updateDeptList,dingshi);
			if (depList!=null&&depList.size()>0) {
				dealDataDao.saveDeptList(depList);
			}
			if (updateDeptList!=null&&updateDeptList.size()>0) {
				dealDataDao.updateDeptList(updateDeptList);
			}
			
			startIndex=startIndex+500;//每次请求500条
		}
		
		logger.info("---------------------核算部门处理完成");
	}
	//同步核算人员
	@Override
	public void syncPersonnel(String sessionId,boolean dingshi) {
		logger.info("-----------------------处理核算人员方法");
		String ryUrl=AppContext.getSystemProperty("gkcwplugin.ryzdUrl");
		//获取计数接口xml参数
		String countxml=getNumXml(sessionId,dingshi);
		logger.info("------------------------计数接口xml参数："+countxml);
		//----1调用计数服务接口
		String res=new SoapsendUtil().postSoap(countxml, ryUrl);
		//logger.info("------------------------计数接口返回数据："+res);
		//获取数据条数
		int count=getCount(res);
		if (count==0) {
			return;
		}
		int num=500;
		int ammount=0;
		//循环次数
		if(count>500) {
			ammount=count/num+1;
			logger.info("--------------次数："+ammount);
			if (count%num==0) {
				ammount=ammount-1;
			}
		}else {
			ammount=1;
		}
		int startIndex=0;
		for(int i=0;i<ammount;i++) {
			logger.info("---------------i="+i+",startIndex:"+startIndex);
			//获取核算人员查询xml
			String queryXml=getQueryXml(sessionId, startIndex,true,dingshi);
			logger.info("------------------------查询接口xml参数："+queryXml);
			//-----2调用核算人员查询接口
			String ry=new SoapsendUtil().postSoap(queryXml, ryUrl);
			//logger.info("------------------------查询接口返回数据："+ry);
			//定义集合，用于存放所有核算人员
			List<Personnel> personList=new ArrayList<Personnel>();
			//更新集合，定时任务用
			List<Personnel> updatePersonList=new ArrayList<Personnel>();
			//获取核算人员记录
			personList=getPersonList(ry, personList,updatePersonList,dingshi);
			if (personList!=null&&personList.size()>0) {
				dealDataDao.savePersonnelList(personList);
			}
			if (updatePersonList!=null&&updatePersonList.size()>0) {
				dealDataDao.updatePersonList(updatePersonList);
			}
			startIndex=startIndex+500;//每次请求500条
		}
		
		logger.info("---------------------核算人员处理完成");
		
	}
	//同步银行账户
	@Override
	public void syncBankAccounts(String sessionId,boolean dingshi) {
		logger.info("------------------------处理银行账户方法");
		String bankAccountUrl=AppContext.getSystemProperty("gkcwplugin.bankAccountUrl");
		//获取计数接口xml参数
		String countxml=getNumXml(sessionId,dingshi);
		logger.info("------------------------计数接口xml参数："+countxml);
		//----1调用计数服务接口
		String res=new SoapsendUtil().postSoap(countxml, bankAccountUrl);
		//logger.info("------------------------计数接口返回数据："+res);
		//获取数据条数
		int count=getCount(res);
		if (count==0) {
			return;
		}
		int num=500;
		int ammount=0;
		//循环次数
		if(count>500) {
			ammount=count/num+1;
			logger.info("--------------次数："+ammount);
			if (count%num==0) {
				ammount=ammount-1;
			}
		}else {
			ammount=1;
		}
		int startIndex=0;
		for(int i = 0; i < ammount; i++) {
			logger.info("---------------i="+i+",startIndex:"+startIndex);
			//获取银行账户查询xml
			String queryXml=getQueryXml(sessionId, startIndex,true,dingshi);
			logger.info("------------------------查询接口xml参数："+queryXml);
			//-----2调用银行账户查询接口
			String bankAccounts=new SoapsendUtil().postSoap(queryXml, bankAccountUrl);
			//logger.info("------------------------查询接口返回数据："+bankAccounts);
			List<BankAccounts> bankAccountList=new ArrayList<BankAccounts>();
			List<BankAccounts> updateBankAccountList=new ArrayList<BankAccounts>();
			//处理银行账户记录
			bankAccountList=getBankAccountList(bankAccounts, bankAccountList,updateBankAccountList,dingshi);
			if (bankAccountList!=null&&bankAccountList.size()>0) {
				dealDataDao.saveBankAccountsList(bankAccountList);
			}
			if (updateBankAccountList!=null&&updateBankAccountList.size()>0) {
				dealDataDao.updateBankAccountList(updateBankAccountList);
			}
			startIndex=startIndex+500;//每次请求500条
		}
		
		logger.info("-----------------------银行账户处理完成");
	}
	//同步核算科目
	public void syncSubject(String sessionId,boolean dingshi) {
		logger.info("-----------------------处理核算科目方法");
		String kmzdUrkl=AppContext.getSystemProperty("gkcwplugin.kmzdUrkl");
		//获取计数接口xml参数
		String countxml=getKMNumXml(sessionId,dingshi);
		logger.info("------------------------计数接口xml参数："+countxml);
		//----1调用计数服务接口
		String res=new SoapsendUtil().postSoap(countxml, kmzdUrkl);
		//logger.info("------------------------计数接口返回数据："+res);
		//获取数据条数
		int count=getCount(res);
		if (count==0) {
			return;
		}
		int num=500;
		int ammount=0;
		//循环次数
		if(count>500) {
			ammount=count/num+1;
			logger.info("--------------次数："+ammount);
			if (count%num==0) {
				ammount=ammount-1;
			}
		}else {
			ammount=1;
		}
		int startIndex=0;
		for(int i = 0; i < ammount; i++) {
			logger.info("---------------i="+i+",startIndex:"+startIndex);
			//获取核算科目查询xml
			//String queryXml=getQueryXml(sessionId, startIndex,false,dingshi);
			String queryXml=getQueryXml(sessionId, startIndex,true,dingshi);
			logger.info("------------------------查询接口xml参数："+queryXml);
			//-----2调用核算科目查询接口
			String km=new SoapsendUtil().postSoap(queryXml, kmzdUrkl);
			//logger.info("------------------------查询接口返回数据："+km);
			List<SubjectPO> subjectList=new ArrayList<SubjectPO>();
			//更新集合
			List<SubjectPO> updateSubjectList=new ArrayList<SubjectPO>();
			//处理核算科目记录
			subjectList=getSubjectList(km, subjectList,updateSubjectList,dingshi);
			if (subjectList!=null&&subjectList.size()>0) {
				dealDataDao.saveSubjectList(subjectList);
			}
			if (updateSubjectList!=null&&updateSubjectList.size()>0) {
				dealDataDao.updateSubjectList(updateSubjectList);
			}
			startIndex=startIndex+500;//每次请求500条
		}
		
		logger.info("-----------------------核算科目处理完成");
	}
	//拼接往来单位查询参数-特殊，数据量大，单次请求条数上限为1000
	public String getUnitQueryXml(String sessionId,int startIndex,boolean flag) {
		String minvalue="";
		String maxvalue="";
		if (flag) {
			Date beforDate=DateUtil.addDay(new Date(), -1);//获取一周前日期
			Date nextDate=DateUtil.addDay(new Date(), 1);
			minvalue=DateUtil.format(beforDate, "yyyy-MM-dd");
			maxvalue=DateUtil.format(nextDate, "yyyy-MM-dd");
		}else {
			Date bDate=DateUtil.addYear(new Date(), -33);
			minvalue=DateUtil.format(bDate, "yyyy-MM-dd");
			maxvalue=DateUtil.getDate("yyyy-MM-dd");
		}
		StringBuffer sb=new StringBuffer();
		sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
		sb.append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:tem=\"http://tempuri.org/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
		sb.append("<soap:Header>");
		sb.append("<tem:GsSession>");
		sb.append("<tem:SessionID>"+sessionId+"</tem:SessionID>");
		sb.append("</tem:GsSession>");
		sb.append("</soap:Header>");
		sb.append("<soap:Body>");
		sb.append("<tem:Query xmlns=\"http://WebXml.com.cn/\">");
		sb.append("<tem:dateRange>");
		sb.append("<tem:MinValue>"+minvalue+"</tem:MinValue>");
		sb.append("<tem:MaxValue>"+maxvalue+"</tem:MaxValue>");
		sb.append("</tem:dateRange>");
		sb.append("<tem:rowRange>");
		sb.append("<tem:Start>"+startIndex+"</tem:Start>");
		sb.append("<tem:Count>1000</tem:Count>");
		sb.append("</tem:rowRange>");
		sb.append("</tem:Query>");
		sb.append("</soap:Body>");
		sb.append("</soap:Envelope>");
		return sb.toString();
	}
	//拼接查询接口参数
	public String getQueryXml(String sessionId,int startIndex,boolean flag,boolean dingshi) {
		
		StringBuffer sb=new StringBuffer();
		sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
		sb.append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:tem=\"http://tempuri.org/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
		sb.append("<soap:Header>");
		sb.append("<tem:GsSession>");
		sb.append("<tem:SessionID>"+sessionId+"</tem:SessionID>");
		sb.append("</tem:GsSession>");
		sb.append("</soap:Header>");
		sb.append("<soap:Body>");
		sb.append("<tem:Query xmlns=\"http://WebXml.com.cn/\">");
		sb.append("<tem:dateRange>");
		if (dingshi) {//如果定时任务调用
			Date beforDate=DateUtil.addDay(new Date(), -1);//获取一周前日期
			Date nextDate=DateUtil.addDay(new Date(), 1);
			String minD=DateUtil.format(beforDate, "yyyy-MM-dd");
			String maxD=DateUtil.format(nextDate, "yyyy-MM-dd");
			sb.append("<tem:MinValue>"+minD+"</tem:MinValue>");
			sb.append("<tem:MaxValue>"+maxD+"</tem:MaxValue>");
		}else {
			Date bDate=DateUtil.addYear(new Date(), -33);
			String minvalue=DateUtil.format(bDate, "yyyy-MM-dd");
			if (!flag) {//核算科目开始日期为今年
				minvalue=DateUtil.getYear()+"-01-01";
			}
			String maxvalue=DateUtil.getDate("yyyy-MM-dd");
			sb.append("<tem:MinValue>"+minvalue+"</tem:MinValue>");
			sb.append("<tem:MaxValue>"+maxvalue+"</tem:MaxValue>");
		}
		
		sb.append("</tem:dateRange>");
		sb.append("<tem:rowRange>");
		sb.append("<tem:Start>"+startIndex+"</tem:Start>");
		sb.append("<tem:Count>500</tem:Count>");
		//sb.append("<tem:Count>"+count+"</tem:Count>");
		sb.append("</tem:rowRange>");
		sb.append("</tem:Query>");
		sb.append("</soap:Body>");
		sb.append("</soap:Envelope>");
		return sb.toString();
	}
	//拼接核算科目计数接口参数
	public String getKMNumXml(String sessionId,boolean dingshi) {
		String minvalue="";
		String maxvalue="";
		if (dingshi) {
			Date beforDate=DateUtil.addDay(new Date(), -7);//获取一周前日期
			Date nextDate=DateUtil.addDay(new Date(), 1);
			minvalue=DateUtil.format(beforDate, "yyyy-MM-dd");
			maxvalue=DateUtil.format(nextDate, "yyyy-MM-dd");
		}else {
			Date bDate=DateUtil.addYear(new Date(), -33);
			minvalue=DateUtil.format(bDate, "yyyy-MM-dd");
			maxvalue=DateUtil.getDate("yyyy-MM-dd");
		}
//		String minvalue=DateUtil.getYear()+"-01-01";
//		String maxvalue=DateUtil.getDate("yyyy-MM-dd");
		StringBuffer sb=new StringBuffer();
		sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
		sb.append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:tem=\"http://tempuri.org/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
		sb.append("<soap:Header>");
		sb.append("<tem:GsSession>");
		sb.append("<tem:SessionID>"+sessionId+"</tem:SessionID>");
		sb.append("</tem:GsSession>");
		sb.append("</soap:Header>");
		sb.append("<soap:Body>");
		sb.append("<Count xmlns=\"http://tempuri.org/\">");
		sb.append("<dateRange>");
		sb.append("<MinValue>"+minvalue+"</MinValue>");
		sb.append("<MaxValue>"+maxvalue+"</MaxValue>");
		sb.append("</dateRange>");
		sb.append("</Count>");
		sb.append("</soap:Body>");
		sb.append("</soap:Envelope>");
		return sb.toString();
	}
	//拼接计数接口参数
	public String getNumXml(String sessionId,boolean flag) {//flag为定时同步标识，true为定时同步
		String minvalue="";
		String maxvalue="";
		if (flag) {
			Date beforDate=DateUtil.addDay(new Date(), -1);//获取一周前日期
			Date nextDate=DateUtil.addDay(new Date(), 1);
			minvalue=DateUtil.format(beforDate, "yyyy-MM-dd");
			maxvalue=DateUtil.format(nextDate, "yyyy-MM-dd");
		}else {
			Date bDate=DateUtil.addYear(new Date(), -33);
			minvalue=DateUtil.format(bDate, "yyyy-MM-dd");
			maxvalue=DateUtil.getDate("yyyy-MM-dd");
		}
		
		StringBuffer sb=new StringBuffer();
		sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
		sb.append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:tem=\"http://tempuri.org/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
		sb.append("<soap:Header>");
		sb.append("<tem:GsSession>");
		sb.append("<tem:SessionID>"+sessionId+"</tem:SessionID>");
		sb.append("</tem:GsSession>");
		sb.append("</soap:Header>");
		sb.append("<soap:Body>");
		sb.append("<Count xmlns=\"http://tempuri.org/\">");
		sb.append("<dateRange>");
		sb.append("<MinValue>"+minvalue+"</MinValue>");
		sb.append("<MaxValue>"+maxvalue+"</MaxValue>");
		sb.append("</dateRange>");
		sb.append("</Count>");
		sb.append("</soap:Body>");
		sb.append("</soap:Envelope>");
		return sb.toString();
		
	}
	//系统登录所需参数
	public String getSystemXml() {
		String usercode=AppContext.getSystemProperty("gkcwplugin.userCode");
		String password=AppContext.getSystemProperty("gkcwplugin.passWord");
		String instance=AppContext.getSystemProperty("gkcwplugin.instance");
		Date date=new Date();
		SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
		String workDate=sf.format(date);
		StringBuffer sb=new StringBuffer();
		sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
				"<soap:Envelope xmlns:tem=\"http://tempuri.org/\" xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\">"
				//"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
					+"<soap:Body>"
					+"<Login xmlns=\"http://tempuri.org/\">"
						+"<secuser>"
							+"<Usercode>"+usercode+"</Usercode>"
							+"<Password>"+password+"</Password>"
							+"<Instance>"+instance+"</Instance>"
							+"<Workdate>"+workDate+"</Workdate>"
						+"</secuser>"
					+"</Login>"
					+" </soap:Body>"  
			    +"</soap:Envelope>"
		);
		logger.info("---------------调用系统登录接口参数xml："+sb.toString());
		return sb.toString();
	}
	//处理银行账户接口返回数据
	public List<BankAccounts> getBankAccountList(String result,List<BankAccounts> bankAccountList,List<BankAccounts> updateBankAccountList,boolean dingshi){
		try {
			//字符串转xml
			Document doc=DocumentHelper.parseText(result);
			//获取根节点
			Element root=doc.getRootElement();
			logger.info("-----------------银行账户查询接口-根节点："+root.getName());
			Iterator iterator=root.element("Body").element("QueryResponse").elementIterator("QueryResult");
			while(iterator.hasNext()) {
				Element element=(Element) iterator.next();
				String r=element.elementTextTrim("Result");
				//logger.info("----------------------银行账户查询接口-result："+result);
				if ("true".equals(r)) {
					Iterator recordsIterator=element.elementIterator("Records");
					while(recordsIterator.hasNext()) {
						Element recordsEle=(Element) recordsIterator.next();
						Iterator detail=recordsEle.elementIterator("BANKACCOUNTS");
						while(detail.hasNext()) {
							Element detElement=(Element)detail.next();
							String BANKACCOUNTID=detElement.elementTextTrim("BANKACCOUNTID");//数据内码
							String BANKACCOUNTCODE=detElement.elementTextTrim("BANKACCOUNTCODE");//银行账号
							String GENERATEBY=detElement.elementTextTrim("GENERATEBY");//来源
							String ISSTOP=detElement.elementTextTrim("ISSTOP");//停用
							String BANKACCOUNTNAME=detElement.elementTextTrim("BANKACCOUNTNAME");//账号名称
							String BANKACCOUNTTYPE=detElement.elementTextTrim("BANKACCOUNTTYPE");//账户类型编号
							String INBANK=detElement.elementTextTrim("INBANK");//所在银行id
							String OFOBJECT=detElement.elementTextTrim("OFOBJECT");//所属单位
							ContactUnit contactUnit=dealDataDao.findUnitByCode(OFOBJECT);
							String TAG=detElement.elementTextTrim("TAG");
							String STATE=detElement.elementTextTrim("STATE");//状态编号
							String NOTE=detElement.elementTextTrim("NOTE");
							String TYPEOF=detElement.elementTextTrim("TYPEOF");
							String ISMAIN=detElement.elementTextTrim("ISMAIN");//是否默认
							String OFCOMPANY=detElement.elementTextTrim("OFCOMPANY");//创建单位编号
							String COUNTRY=detElement.elementTextTrim("COUNTRY");//国家
							String PROVINCE=detElement.elementTextTrim("PROVINCE");//省份
							String CITY=detElement.elementTextTrim("CITY");//城市
							String ctime=detElement.elementTextTrim("CREATEDTIME");//创建时间
							Date CREATEDTIME=getTimes(ctime);
							String ltime=detElement.elementTextTrim("LASTMODIFIEDTIME");//最后修改时间
							Date LASTMODIFIEDTIME=getTimes(ltime);
							String CREATOR=detElement.elementTextTrim("CREATOR");//创建人
							String LASTMODIFIER=detElement.elementTextTrim("LASTMODIFIER");//最后修改人
							String LSWLDWID=detElement.elementTextTrim("LSWLDWID");//往来单位id
							String BANKACCOUNTCURRENCY=detElement.elementTextTrim("BANKACCOUNTCURRENCY");//币种
							String ISENTERPRISEACCOUNT=detElement.elementTextTrim("ISENTERPRISEACCOUNT");//企业户
							String INOUTFLAG=detElement.elementTextTrim("INOUTFLAG");//内外标志
							String ISONLINEPAY=detElement.elementTextTrim("ISONLINEPAY");//银企直连
							String DJZT=detElement.elementTextTrim("DJZT");//单据状态
							String LCSL=detElement.elementTextTrim("LCSL");//流程实例
							String ELECTICKETBANK=detElement.elementTextTrim("ELECTICKETBANK");//电票开户行
							String BANKACCOUNTALIAS=detElement.elementTextTrim("BANKACCOUNTALIAS");//账户别名
							if (dingshi) {
								BankAccounts oldBankAccounts=dealDataDao.findBankAccountsByNm(BANKACCOUNTID);
								if (oldBankAccounts!=null) {
									oldBankAccounts.setBANKACCOUNTCODE(BANKACCOUNTCODE);
									oldBankAccounts.setGENERATEBY(GENERATEBY);
									oldBankAccounts.setISSTOP(ISSTOP);
									oldBankAccounts.setBANKACCOUNTNAME(BANKACCOUNTNAME);
									oldBankAccounts.setBANKACCOUNTTYPE(BANKACCOUNTTYPE);
									oldBankAccounts.setINBANK(INBANK);
									oldBankAccounts.setOFOBJECT(OFOBJECT);
									if (contactUnit!=null) {
										oldBankAccounts.setDwmc(contactUnit.getLSWLDW_DWMC());
										oldBankAccounts.setNBDW(contactUnit.getLSWLDW_NBDW());
									}
									oldBankAccounts.setTAG(TAG);
									oldBankAccounts.setSTATE(STATE);
									oldBankAccounts.setNOTE(NOTE);
									oldBankAccounts.setTYPEOF(TYPEOF);
									oldBankAccounts.setISMAIN(ISMAIN);
									oldBankAccounts.setOFCOMPANY(OFCOMPANY);
									oldBankAccounts.setCOUNTRY(COUNTRY);
									oldBankAccounts.setPROVINCE(PROVINCE);
									oldBankAccounts.setCITY(CITY);
									oldBankAccounts.setCREATEDTIME(CREATEDTIME);
									oldBankAccounts.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
									oldBankAccounts.setCREATOR(CREATOR);
									oldBankAccounts.setLASTMODIFIER(LASTMODIFIER);
									oldBankAccounts.setLSWLDWID(LSWLDWID);
									oldBankAccounts.setBANKACCOUNTCURRENCY(BANKACCOUNTCURRENCY);
									oldBankAccounts.setISENTERPRISEACCOUNT(ISENTERPRISEACCOUNT);
									oldBankAccounts.setINOUTFLAG(INOUTFLAG);
									oldBankAccounts.setISONLINEPAY(ISONLINEPAY);
									oldBankAccounts.setDJZT(DJZT);
									oldBankAccounts.setLCSL(LCSL);
									oldBankAccounts.setELECTICKETBANK(ELECTICKETBANK);
									oldBankAccounts.setBANKACCOUNTALIAS(BANKACCOUNTALIAS);
									//银行信息
									Iterator banksIterator=detElement.elementIterator("BANKSARRAY");
									while(banksIterator.hasNext()) {
										Element banksEle=(Element) banksIterator.next();
										Iterator banksIte=banksEle.elementIterator("BANKS");
										while(banksIte.hasNext()) {
											Element bankEle=(Element) banksIte.next();
											String BANKID=bankEle.elementTextTrim("BANKID");//ID 银行标识符
											String FULLNAME=bankEle.elementTextTrim("FULLNAME");//银行名称
											String LHH=bankEle.elementTextTrim("LHH");//联行号
											oldBankAccounts.setBANKID(BANKID);
											oldBankAccounts.setFULLNAME(FULLNAME);
											oldBankAccounts.setLHH(LHH);
										}
									}
									updateBankAccountList.add(oldBankAccounts);
								}else {
									BankAccounts bankAccounts=new BankAccounts();
									bankAccounts.setIdIfNew();
									bankAccounts.setBANKACCOUNTID(BANKACCOUNTID);
									bankAccounts.setBANKACCOUNTCODE(BANKACCOUNTCODE);
									bankAccounts.setGENERATEBY(GENERATEBY);
									bankAccounts.setISSTOP(ISSTOP);
									bankAccounts.setBANKACCOUNTNAME(BANKACCOUNTNAME);
									bankAccounts.setBANKACCOUNTTYPE(BANKACCOUNTTYPE);
									bankAccounts.setINBANK(INBANK);
									bankAccounts.setOFOBJECT(OFOBJECT);
									if (contactUnit!=null) {
										bankAccounts.setDwmc(contactUnit.getLSWLDW_DWMC());
										bankAccounts.setNBDW(contactUnit.getLSWLDW_NBDW());
									}
									bankAccounts.setTAG(TAG);
									bankAccounts.setSTATE(STATE);
									bankAccounts.setNOTE(NOTE);
									bankAccounts.setTYPEOF(TYPEOF);
									bankAccounts.setISMAIN(ISMAIN);
									bankAccounts.setOFCOMPANY(OFCOMPANY);
									bankAccounts.setCOUNTRY(COUNTRY);
									bankAccounts.setPROVINCE(PROVINCE);
									bankAccounts.setCITY(CITY);
									bankAccounts.setCREATEDTIME(CREATEDTIME);
									bankAccounts.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
									bankAccounts.setCREATOR(CREATOR);
									bankAccounts.setLASTMODIFIER(LASTMODIFIER);
									bankAccounts.setLSWLDWID(LSWLDWID);
									bankAccounts.setBANKACCOUNTCURRENCY(BANKACCOUNTCURRENCY);
									bankAccounts.setISENTERPRISEACCOUNT(ISENTERPRISEACCOUNT);
									bankAccounts.setINOUTFLAG(INOUTFLAG);
									bankAccounts.setISONLINEPAY(ISONLINEPAY);
									bankAccounts.setDJZT(DJZT);
									bankAccounts.setLCSL(LCSL);
									bankAccounts.setELECTICKETBANK(ELECTICKETBANK);
									bankAccounts.setBANKACCOUNTALIAS(BANKACCOUNTALIAS);
									//银行信息
									Iterator banksIterator=detElement.elementIterator("BANKSARRAY");
									while(banksIterator.hasNext()) {
										Element banksEle=(Element) banksIterator.next();
										Iterator banksIte=banksEle.elementIterator("BANKS");
										while(banksIte.hasNext()) {
											Element bankEle=(Element) banksIte.next();
											String BANKID=bankEle.elementTextTrim("BANKID");//ID 银行标识符
											String FULLNAME=bankEle.elementTextTrim("FULLNAME");//银行名称
											String LHH=bankEle.elementTextTrim("LHH");//联行号
											bankAccounts.setBANKID(BANKID);
											bankAccounts.setFULLNAME(FULLNAME);
											bankAccounts.setLHH(LHH);
										}
									}
									bankAccountList.add(bankAccounts);
								}
							}else {
								BankAccounts bankAccounts=new BankAccounts();
								bankAccounts.setIdIfNew();
								bankAccounts.setBANKACCOUNTID(BANKACCOUNTID);
								bankAccounts.setBANKACCOUNTCODE(BANKACCOUNTCODE);
								bankAccounts.setGENERATEBY(GENERATEBY);
								bankAccounts.setISSTOP(ISSTOP);
								bankAccounts.setBANKACCOUNTNAME(BANKACCOUNTNAME);
								bankAccounts.setBANKACCOUNTTYPE(BANKACCOUNTTYPE);
								bankAccounts.setINBANK(INBANK);
								bankAccounts.setOFOBJECT(OFOBJECT);
								if (contactUnit!=null) {
									bankAccounts.setDwmc(contactUnit.getLSWLDW_DWMC());
									bankAccounts.setNBDW(contactUnit.getLSWLDW_NBDW());
								}
								bankAccounts.setTAG(TAG);
								bankAccounts.setSTATE(STATE);
								bankAccounts.setNOTE(NOTE);
								bankAccounts.setTYPEOF(TYPEOF);
								bankAccounts.setISMAIN(ISMAIN);
								bankAccounts.setOFCOMPANY(OFCOMPANY);
								bankAccounts.setCOUNTRY(COUNTRY);
								bankAccounts.setPROVINCE(PROVINCE);
								bankAccounts.setCITY(CITY);
								bankAccounts.setCREATEDTIME(CREATEDTIME);
								bankAccounts.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
								bankAccounts.setCREATOR(CREATOR);
								bankAccounts.setLASTMODIFIER(LASTMODIFIER);
								bankAccounts.setLSWLDWID(LSWLDWID);
								bankAccounts.setBANKACCOUNTCURRENCY(BANKACCOUNTCURRENCY);
								bankAccounts.setISENTERPRISEACCOUNT(ISENTERPRISEACCOUNT);
								bankAccounts.setINOUTFLAG(INOUTFLAG);
								bankAccounts.setISONLINEPAY(ISONLINEPAY);
								bankAccounts.setDJZT(DJZT);
								bankAccounts.setLCSL(LCSL);
								bankAccounts.setELECTICKETBANK(ELECTICKETBANK);
								bankAccounts.setBANKACCOUNTALIAS(BANKACCOUNTALIAS);
								//银行信息
								Iterator banksIterator=detElement.elementIterator("BANKSARRAY");
								while(banksIterator.hasNext()) {
									Element banksEle=(Element) banksIterator.next();
									Iterator banksIte=banksEle.elementIterator("BANKS");
									while(banksIte.hasNext()) {
										Element bankEle=(Element) banksIte.next();
										String BANKID=bankEle.elementTextTrim("BANKID");//ID 银行标识符
										String FULLNAME=bankEle.elementTextTrim("FULLNAME");//银行名称
										String LHH=bankEle.elementTextTrim("LHH");//联行号
										bankAccounts.setBANKID(BANKID);
										bankAccounts.setFULLNAME(FULLNAME);
										bankAccounts.setLHH(LHH);
									}
								}
								bankAccountList.add(bankAccounts);
							}
							
						}
					}
				}
			}
			logger.info("----------------------bankAccountList科目集合长度:"+bankAccountList.size());
			return bankAccountList;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	//处理核算人员接口返回数据
	public List<Personnel> getPersonList(String result,List<Personnel> personList,List<Personnel> updatePersonList,boolean dingshi){
		try {
			//字符串转xml
			Document doc=DocumentHelper.parseText(result);
			//获取根节点
			Element root=doc.getRootElement();
			logger.info("-----------------核算人员查询接口-根节点："+root.getName());
			Iterator iterator=root.element("Body").element("QueryResponse").elementIterator("QueryResult");
			while(iterator.hasNext()) {
				Element element=(Element) iterator.next();
				String r=element.elementTextTrim("Result");
				//logger.info("----------------------核算人员查询接口-result："+result);
				if ("true".equals(r)) {
					logger.info("-----------------true");
					Iterator recordsIterator=element.elementIterator("Records");
					while(recordsIterator.hasNext()) {
						Element recordsEle=(Element) recordsIterator.next();
						Iterator detail=recordsEle.elementIterator("LSZGZD");
						while(detail.hasNext()) {
							Element detElement=(Element)detail.next();
							String LSZGZD_ID=detElement.elementTextTrim("LSZGZD_ID");//部门标识;//职工id
							String LSZGZD_DWBH=detElement.elementTextTrim("LSZGZD_DWBH");//单位编号
							String LSZGZD_LXDH=detElement.elementTextTrim("LSZGZD_LXDH");//联系电话
							String LSZGZD_BMBH=detElement.elementTextTrim("LSZGZD_BMBH");//部门编号
							DepartmentPO deptPO=dealDataDao.findDeptByCode(LSZGZD_BMBH, LSZGZD_DWBH);
							String bmmc=deptPO.getLSBMZD_BMMC();
							String dwmc=deptPO.getLSBMZD_DWMC();
							String LSZGZD_CRC=detElement.elementTextTrim("LSZGZD_CRC");//密级
							String LSZGZD_ZGBH=detElement.elementTextTrim("LSZGZD_ZGBH");//员工编号
							String LSZGZD_ZJM=detElement.elementTextTrim("LSZGZD_ZJM");//助记码
							String LSZGZD_ZGXM=detElement.elementTextTrim("LSZGZD_ZGXM");//员工姓名
							String LSZGZD_RYSX=detElement.elementTextTrim("LSZGZD_RYSX");//人员属性
							String LSZGZD_USERID=detElement.elementTextTrim("LSZGZD_USERID");//操作用户id
							String LSZGZD_ZWBZ=detElement.elementTextTrim("LSZGZD_ZWBZ");//会计核算标志
							String LSZGZD_YGNM=detElement.elementTextTrim("LSZGZD_YGNM");//员工内码
							String LSZGZD_WJRY=detElement.elementTextTrim("LSZGZD_WJRY");//外籍人员
							String LSZGZD_YHBH=detElement.elementTextTrim("LSZGZD_YHBH");//银行编号
							String LSZGZD_YHZH=detElement.elementTextTrim("LSZGZD_YHZH");//银行账户
							String LSZGZD_YGID=detElement.elementTextTrim("LSZGZD_YGID");//员工身份证号
							String LSZGZD_EMAL=detElement.elementTextTrim("LSZGZD_EMAL");//email
							String LSZGZD_TYBZ=detElement.elementTextTrim("LSZGZD_TYBZ");//停用标志
							String LSZGZD_TYND=detElement.elementTextTrim("LSZGZD_TYND");//停用年度
							String LSZGZD_TBBZ=detElement.elementTextTrim("LSZGZD_TBBZ");//同步标识
							String HRZGZD_XRZW=detElement.elementTextTrim("HRZGZD_XRZW");//职务
							String HRZGZD_SFZH=detElement.elementTextTrim("HRZGZD_SFZH");//身份证号
							String HRZGZD_ZGXB=detElement.elementTextTrim("HRZGZD_ZGXB");//性别
							String csrq=detElement.elementTextTrim("HRZGZD_CSRQ");//出生日期
							String HRZGZD_CSRQ="";
							if (!"".equals(csrq)) {
								HRZGZD_CSRQ=getTimeStr(csrq);
							}
							String rzrq=detElement.elementTextTrim("HRZGZD_RDSJ");//入职日期
							String HRZGZD_RDSJ="";
							if (!"".equals(rzrq)) {
								HRZGZD_RDSJ=getTimeStr(rzrq);
							}
							String lzrq=detElement.elementTextTrim("HRZGZD_LZSJ");//离职日期
							String HRZGZD_LZSJ="";
							if (!"".equals(lzrq)) {
								HRZGZD_LZSJ=getTimeStr(lzrq);
							}
							String LSZGZD_YGLB=detElement.elementTextTrim("LSZGZD_YGLB");//员工类别
							String LSZGZD_NOTE=detElement.elementTextTrim("LSZGZD_NOTE");//备注
							String LSZGZD_HRDW=detElement.elementTextTrim("LSZGZD_HRDW");//行政组织
							String LSZGZD_HRZG=detElement.elementTextTrim("LSZGZD_HRZG");//HR人员
							String CREATEUSER=detElement.elementTextTrim("CREATEUSER");//创建人
							String cTime=detElement.elementTextTrim("CREATETIME");//创建时间
							Date CREATETIME=null;
							if (!"".equals(cTime)) {
								CREATETIME=getTimes(cTime);
							}
							String LASTMODIFIEDUSER=detElement.elementTextTrim("LASTMODIFIEDUSER");//最后修改人
							String lTime=detElement.elementTextTrim("LASTMODIFIEDTIME");//最后修改时间
							Date LASTMODIFIEDTIME=null;
							if (!"".equals(lTime)) {
								LASTMODIFIEDTIME=getTimes(lTime);
							}
							String CONSUMACCOUNT=detElement.elementTextTrim("CONSUMACCOUNT");
							String REGUSERID=detElement.elementTextTrim("REGUSERID");
							String LSZGZD_CUSTOMFILED1=detElement.elementTextTrim("LSZGZD_CUSTOMFILED1");//自定义项
							if (dingshi) {
								Personnel oldPersonnel=dealDataDao.findPersonById(LSZGZD_ID);
								if (oldPersonnel!=null) {
									oldPersonnel.setLSZGZD_DWBH(LSZGZD_DWBH);
									oldPersonnel.setLSZGZD_LXDH(LSZGZD_LXDH);
									oldPersonnel.setLSZGZD_BMBH(LSZGZD_BMBH);
									oldPersonnel.setLSZGZD_CRC(LSZGZD_CRC);
									oldPersonnel.setLSZGZD_ZGBH(LSZGZD_ZGBH);
									oldPersonnel.setLSZGZD_ZJM(LSZGZD_ZJM);
									oldPersonnel.setLSZGZD_ZGXM(LSZGZD_ZGXM);
									oldPersonnel.setLSZGZD_RYSX(LSZGZD_RYSX);
									oldPersonnel.setLSZGZD_USERID(LSZGZD_USERID);
									oldPersonnel.setLSZGZD_ZWBZ(LSZGZD_ZWBZ);
									oldPersonnel.setLSZGZD_YGNM(LSZGZD_YGNM);
									oldPersonnel.setLSZGZD_WJRY(LSZGZD_WJRY);
									oldPersonnel.setLSZGZD_YHBH(LSZGZD_YHBH);
									oldPersonnel.setLSZGZD_YHZH(LSZGZD_YHZH);
									oldPersonnel.setLSZGZD_YGID(LSZGZD_YGID);
									oldPersonnel.setLSZGZD_EMAL(LSZGZD_EMAL);
									oldPersonnel.setLSZGZD_TYBZ(LSZGZD_TYBZ);
									oldPersonnel.setLSZGZD_TYND(LSZGZD_TYND);
									oldPersonnel.setLSZGZD_TBBZ(LSZGZD_TBBZ);
									oldPersonnel.setHRZGZD_XRZW(HRZGZD_XRZW);
									oldPersonnel.setHRZGZD_SFZH(HRZGZD_SFZH);
									oldPersonnel.setHRZGZD_ZGXB(HRZGZD_ZGXB);
									oldPersonnel.setHRZGZD_CSRQ(HRZGZD_CSRQ);
									oldPersonnel.setHRZGZD_RDSJ(HRZGZD_RDSJ);
									oldPersonnel.setHRZGZD_LZSJ(HRZGZD_LZSJ);
									oldPersonnel.setLSZGZD_YGLB(LSZGZD_YGLB);
									oldPersonnel.setLSZGZD_NOTE(LSZGZD_NOTE);
									oldPersonnel.setLSZGZD_HRDW(LSZGZD_HRDW);
									oldPersonnel.setLSZGZD_HRZG(LSZGZD_HRZG);
									oldPersonnel.setCREATEUSER(CREATEUSER);
									oldPersonnel.setCREATETIME(CREATETIME);
									oldPersonnel.setLASTMODIFIEDUSER(LASTMODIFIEDUSER);
									oldPersonnel.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
									oldPersonnel.setCONSUMACCOUNT(CONSUMACCOUNT);
									oldPersonnel.setREGUSERID(REGUSERID);
									oldPersonnel.setLSZGZD_CUSTOMFILED1(LSZGZD_CUSTOMFILED1);
									oldPersonnel.setBmmc(bmmc);
									oldPersonnel.setDwmc(dwmc);
									updatePersonList.add(oldPersonnel);
								}else {
									Personnel p=new Personnel();
									p.setIdIfNew();
									p.setLSZGZD_ID(LSZGZD_ID);
									p.setLSZGZD_DWBH(LSZGZD_DWBH);
									p.setLSZGZD_LXDH(LSZGZD_LXDH);
									p.setLSZGZD_BMBH(LSZGZD_BMBH);
									p.setLSZGZD_CRC(LSZGZD_CRC);
									p.setLSZGZD_ZGBH(LSZGZD_ZGBH);
									p.setLSZGZD_ZJM(LSZGZD_ZJM);
									p.setLSZGZD_ZGXM(LSZGZD_ZGXM);
									p.setLSZGZD_RYSX(LSZGZD_RYSX);
									p.setLSZGZD_USERID(LSZGZD_USERID);
									p.setLSZGZD_ZWBZ(LSZGZD_ZWBZ);
									p.setLSZGZD_YGNM(LSZGZD_YGNM);
									p.setLSZGZD_WJRY(LSZGZD_WJRY);
									p.setLSZGZD_YHBH(LSZGZD_YHBH);
									p.setLSZGZD_YHZH(LSZGZD_YHZH);
									p.setLSZGZD_YGID(LSZGZD_YGID);
									p.setLSZGZD_EMAL(LSZGZD_EMAL);
									p.setLSZGZD_TYBZ(LSZGZD_TYBZ);
									p.setLSZGZD_TYND(LSZGZD_TYND);
									p.setLSZGZD_TBBZ(LSZGZD_TBBZ);
									p.setHRZGZD_XRZW(HRZGZD_XRZW);
									p.setHRZGZD_SFZH(HRZGZD_SFZH);
									p.setHRZGZD_ZGXB(HRZGZD_ZGXB);
									p.setHRZGZD_CSRQ(HRZGZD_CSRQ);
									p.setHRZGZD_RDSJ(HRZGZD_RDSJ);
									p.setHRZGZD_LZSJ(HRZGZD_LZSJ);
									p.setLSZGZD_YGLB(LSZGZD_YGLB);
									p.setLSZGZD_NOTE(LSZGZD_NOTE);
									p.setLSZGZD_HRDW(LSZGZD_HRDW);
									p.setLSZGZD_HRZG(LSZGZD_HRZG);
									p.setCREATEUSER(CREATEUSER);
									p.setCREATETIME(CREATETIME);
									p.setLASTMODIFIEDUSER(LASTMODIFIEDUSER);
									p.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
									p.setCONSUMACCOUNT(CONSUMACCOUNT);
									p.setREGUSERID(REGUSERID);
									p.setLSZGZD_CUSTOMFILED1(LSZGZD_CUSTOMFILED1);
									p.setBmmc(bmmc);
									p.setDwmc(dwmc);
									personList.add(p);
								}
							}else {
								Personnel p=new Personnel();
								p.setIdIfNew();
								p.setLSZGZD_ID(LSZGZD_ID);
								p.setLSZGZD_DWBH(LSZGZD_DWBH);
								p.setLSZGZD_LXDH(LSZGZD_LXDH);
								p.setLSZGZD_BMBH(LSZGZD_BMBH);
								p.setLSZGZD_CRC(LSZGZD_CRC);
								p.setLSZGZD_ZGBH(LSZGZD_ZGBH);
								p.setLSZGZD_ZJM(LSZGZD_ZJM);
								p.setLSZGZD_ZGXM(LSZGZD_ZGXM);
								p.setLSZGZD_RYSX(LSZGZD_RYSX);
								p.setLSZGZD_USERID(LSZGZD_USERID);
								p.setLSZGZD_ZWBZ(LSZGZD_ZWBZ);
								p.setLSZGZD_YGNM(LSZGZD_YGNM);
								p.setLSZGZD_WJRY(LSZGZD_WJRY);
								p.setLSZGZD_YHBH(LSZGZD_YHBH);
								p.setLSZGZD_YHZH(LSZGZD_YHZH);
								p.setLSZGZD_YGID(LSZGZD_YGID);
								p.setLSZGZD_EMAL(LSZGZD_EMAL);
								p.setLSZGZD_TYBZ(LSZGZD_TYBZ);
								p.setLSZGZD_TYND(LSZGZD_TYND);
								p.setLSZGZD_TBBZ(LSZGZD_TBBZ);
								p.setHRZGZD_XRZW(HRZGZD_XRZW);
								p.setHRZGZD_SFZH(HRZGZD_SFZH);
								p.setHRZGZD_ZGXB(HRZGZD_ZGXB);
								p.setHRZGZD_CSRQ(HRZGZD_CSRQ);
								p.setHRZGZD_RDSJ(HRZGZD_RDSJ);
								p.setHRZGZD_LZSJ(HRZGZD_LZSJ);
								p.setLSZGZD_YGLB(LSZGZD_YGLB);
								p.setLSZGZD_NOTE(LSZGZD_NOTE);
								p.setLSZGZD_HRDW(LSZGZD_HRDW);
								p.setLSZGZD_HRZG(LSZGZD_HRZG);
								p.setCREATEUSER(CREATEUSER);
								p.setCREATETIME(CREATETIME);
								p.setLASTMODIFIEDUSER(LASTMODIFIEDUSER);
								p.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
								p.setCONSUMACCOUNT(CONSUMACCOUNT);
								p.setREGUSERID(REGUSERID);
								p.setLSZGZD_CUSTOMFILED1(LSZGZD_CUSTOMFILED1);
								p.setBmmc(bmmc);
								p.setDwmc(dwmc);
								personList.add(p);
							}
							
						}
					}
				}
			}
			logger.info("------------------------核算人员集合长度personList:"+personList.size());
			return personList;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	//处理核算部门接口返回数据
	public List<DepartmentPO> getDeptList(String result,List<DepartmentPO> deptList,List<DepartmentPO> updateDeptList,boolean dingshi){
		try {
			//字符串转xml
			Document doc=DocumentHelper.parseText(result);
			//获取根节点
			Element root=doc.getRootElement();
			logger.info("-----------------核算部门查询接口-根节点："+root.getName());
			Iterator iterator=root.element("Body").element("QueryResponse").elementIterator("QueryResult");
			while(iterator.hasNext()) {
				Element element=(Element) iterator.next();
				String r=element.elementTextTrim("Result");
				//logger.info("----------------------核算部门查询接口-result："+result);
				if ("true".equals(r)) {
					Iterator recordsIterator=element.elementIterator("Records");
					while(recordsIterator.hasNext()) {
						Element recordsEle=(Element) recordsIterator.next();
						Iterator detail=recordsEle.elementIterator("LSBMZD");
						while(detail.hasNext()) {
							Element detElement=(Element)detail.next();
							//循环数据集（while/for），往depList赋值 
							String LSBMZD_ID=detElement.elementTextTrim("LSBMZD_ID");//部门标识
							String LSBMZD_DWBH=detElement.elementTextTrim("LSBMZD_DWBH");//公司编号
							String LSBMZD_DWMC=detElement.elementTextTrim("LSBMZD_DWMC");//公司名称
							String LSBMZD_BMBH=detElement.elementTextTrim("LSBMZD_BMBH");//部门编号
							String LSBMZD_ZJM=detElement.elementTextTrim("LSBMZD_ZJM");//助记码
							String LSBMZD_BMMC=detElement.elementTextTrim("LSBMZD_BMMC");//部门名称
							String LSBMZD_JS=detElement.elementTextTrim("LSBMZD_JS");//级数
							String LSBMZD_MX=detElement.elementTextTrim("LSBMZD_MX");//是否明细0非明细1明细 如果当前节点存在子节点，则取值0，否则取值1。
							String LSBMZD_FJM=detElement.elementTextTrim("LSBMZD_FJM");//分级码
							String LSBMZD_LX=detElement.elementTextTrim("LSBMZD_LX");//部门类型销售 
							String LSBMZD_DYDW=detElement.elementTextTrim("LSBMZD_DYDW");//对应单位
							String LSBMZD_DYBM=detElement.elementTextTrim("LSBMZD_DYBM");//对应部门
							String LSBMZD_SX=detElement.elementTextTrim("LSBMZD_SX");//部门属性
							String LSBMZD_HSF=detElement.elementTextTrim("LSBMZD_HSF");//会计核算否0不核算1核算
							String LSBMZD_TYBZ=detElement.elementTextTrim("LSBMZD_TYBZ");//停用标志0未停用1停用
							String LSBMZD_TYND=detElement.elementTextTrim("LSBMZD_TYND");//停用年度
							String CREATEUSER=detElement.elementTextTrim("CREATEUSER");//创建人
							String cTime=detElement.elementTextTrim("CREATETIME");
							Date CREATETIME=getTimes(cTime);
							String LASTMODIFIEDUSER=detElement.elementTextTrim("LASTMODIFIEDUSER");//最后修改人
							String ltime=detElement.elementTextTrim("LASTMODIFIEDTIME");
							Date LASTMODIFIEDTIME=getTimes(ltime);
							String LSBMZD_BMFZR=detElement.elementTextTrim("LSBMZD_BMFZR");//部门负责人
							String LSBMZD_HSST=detElement.elementTextTrim("LSBMZD_HSST");//核算实体
							String LSBMZD_BMQC=detElement.elementTextTrim("LSBMZD_BMQC");//部门全称
							String LSBMZD_BMFGLD=detElement.elementTextTrim("LSBMZD_BMFGLD");//部门分管领导
							String LSBMZD_CUSTOMFILED1=detElement.elementTextTrim("LSBMZD_CUSTOMFILED1");//自定义字段1
							String LSBMZD_FZLDNAME=detElement.elementTextTrim("LSBMZD_FZLDNAME");//副职领导名称
							String LSBMZD_FZLDID=detElement.elementTextTrim("LSBMZD_FZLDID");//副职领导内码
							String LSBMZD_HRDEPTID=detElement.elementTextTrim("LSBMZD_HRDEPTID");//行政部门内码
							
							if (dingshi) {
								DepartmentPO olDepartPO=dealDataDao.findDeptById(LSBMZD_ID);
								if (olDepartPO!=null) {
									olDepartPO.setLSBMZD_DWBH(LSBMZD_DWBH);
									olDepartPO.setLSBMZD_DWMC(LSBMZD_DWMC);
									olDepartPO.setLSBMZD_BMBH(LSBMZD_BMBH);
									olDepartPO.setLSBMZD_ZJM(LSBMZD_ZJM);
									olDepartPO.setLSBMZD_BMMC(LSBMZD_BMMC);
									olDepartPO.setLSBMZD_JS(Integer.parseInt(LSBMZD_JS));
									olDepartPO.setLSBMZD_MX(LSBMZD_MX);
									olDepartPO.setLSBMZD_FJM(LSBMZD_FJM);
									olDepartPO.setLSBMZD_LX(LSBMZD_LX);
									olDepartPO.setLSBMZD_DYDW(LSBMZD_DYDW);
									olDepartPO.setLSBMZD_DYBM(LSBMZD_DYBM);
									olDepartPO.setLSBMZD_SX(LSBMZD_SX);
									olDepartPO.setLSBMZD_HSF(LSBMZD_HSF);
									olDepartPO.setLSBMZD_TYBZ(LSBMZD_TYBZ);
									olDepartPO.setLSBMZD_TYND(LSBMZD_TYND);
									olDepartPO.setCREATEUSER(CREATEUSER);
									olDepartPO.setCREATETIME(CREATETIME);
									olDepartPO.setLASTMODIFIEDUSER(LASTMODIFIEDUSER);
									olDepartPO.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
									olDepartPO.setLSBMZD_BMFZR(LSBMZD_BMFZR);
									olDepartPO.setLSBMZD_HSST(LSBMZD_HSST);
									olDepartPO.setLSBMZD_BMQC(LSBMZD_BMQC);
									olDepartPO.setLSBMZD_BMFGLD(LSBMZD_BMFGLD);
									olDepartPO.setLSBMZD_CUSTOMFILED1(LSBMZD_CUSTOMFILED1);
									olDepartPO.setLSBMZD_FZLDNAME(LSBMZD_FZLDNAME);
									olDepartPO.setLSBMZD_FZLDID(LSBMZD_FZLDID);
									olDepartPO.setLSBMZD_HRDEPTID(LSBMZD_HRDEPTID);
									updateDeptList.add(olDepartPO);
								}else {
									DepartmentPO dep=new DepartmentPO();
									dep.setIdIfNew();
									dep.setLSBMZD_ID(LSBMZD_ID);
									dep.setLSBMZD_DWBH(LSBMZD_DWBH);
									dep.setLSBMZD_DWMC(LSBMZD_DWMC);
									dep.setLSBMZD_BMBH(LSBMZD_BMBH);
									dep.setLSBMZD_ZJM(LSBMZD_ZJM);
									dep.setLSBMZD_BMMC(LSBMZD_BMMC);
									dep.setLSBMZD_JS(Integer.parseInt(LSBMZD_JS));
									dep.setLSBMZD_MX(LSBMZD_MX);
									dep.setLSBMZD_FJM(LSBMZD_FJM);
									dep.setLSBMZD_LX(LSBMZD_LX);
									dep.setLSBMZD_DYDW(LSBMZD_DYDW);
									dep.setLSBMZD_DYBM(LSBMZD_DYBM);
									dep.setLSBMZD_SX(LSBMZD_SX);
									dep.setLSBMZD_HSF(LSBMZD_HSF);
									dep.setLSBMZD_TYBZ(LSBMZD_TYBZ);
									dep.setLSBMZD_TYND(LSBMZD_TYND);
									dep.setCREATEUSER(CREATEUSER);
									dep.setCREATETIME(CREATETIME);
									dep.setLASTMODIFIEDUSER(LASTMODIFIEDUSER);
									dep.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
									dep.setLSBMZD_BMFZR(LSBMZD_BMFZR);
									dep.setLSBMZD_HSST(LSBMZD_HSST);
									dep.setLSBMZD_BMQC(LSBMZD_BMQC);
									dep.setLSBMZD_BMFGLD(LSBMZD_BMFGLD);
									dep.setLSBMZD_CUSTOMFILED1(LSBMZD_CUSTOMFILED1);
									dep.setLSBMZD_FZLDNAME(LSBMZD_FZLDNAME);
									dep.setLSBMZD_FZLDID(LSBMZD_FZLDID);
									dep.setLSBMZD_HRDEPTID(LSBMZD_HRDEPTID);
									deptList.add(dep);
								}
							}else {
								DepartmentPO dep=new DepartmentPO();
								dep.setIdIfNew();
								dep.setLSBMZD_ID(LSBMZD_ID);
								dep.setLSBMZD_DWBH(LSBMZD_DWBH);
								dep.setLSBMZD_DWMC(LSBMZD_DWMC);
								dep.setLSBMZD_BMBH(LSBMZD_BMBH);
								dep.setLSBMZD_ZJM(LSBMZD_ZJM);
								dep.setLSBMZD_BMMC(LSBMZD_BMMC);
								dep.setLSBMZD_JS(Integer.parseInt(LSBMZD_JS));
								dep.setLSBMZD_MX(LSBMZD_MX);
								dep.setLSBMZD_FJM(LSBMZD_FJM);
								dep.setLSBMZD_LX(LSBMZD_LX);
								dep.setLSBMZD_DYDW(LSBMZD_DYDW);
								dep.setLSBMZD_DYBM(LSBMZD_DYBM);
								dep.setLSBMZD_SX(LSBMZD_SX);
								dep.setLSBMZD_HSF(LSBMZD_HSF);
								dep.setLSBMZD_TYBZ(LSBMZD_TYBZ);
								dep.setLSBMZD_TYND(LSBMZD_TYND);
								dep.setCREATEUSER(CREATEUSER);
								dep.setCREATETIME(CREATETIME);
								dep.setLASTMODIFIEDUSER(LASTMODIFIEDUSER);
								dep.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
								dep.setLSBMZD_BMFZR(LSBMZD_BMFZR);
								dep.setLSBMZD_HSST(LSBMZD_HSST);
								dep.setLSBMZD_BMQC(LSBMZD_BMQC);
								dep.setLSBMZD_BMFGLD(LSBMZD_BMFGLD);
								dep.setLSBMZD_CUSTOMFILED1(LSBMZD_CUSTOMFILED1);
								dep.setLSBMZD_FZLDNAME(LSBMZD_FZLDNAME);
								dep.setLSBMZD_FZLDID(LSBMZD_FZLDID);
								dep.setLSBMZD_HRDEPTID(LSBMZD_HRDEPTID);
								deptList.add(dep);
							}
							
						}
					}
				}
			}
			logger.info("---------------------depList部门集合长度:"+deptList.size());
			return deptList;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	//处理核算科目接口返回数据
	public List<SubjectPO> getSubjectList(String result,List<SubjectPO> subjectList,List<SubjectPO> updateSubjectList,boolean dingshi){
		try {
			//字符串转xml
			Document doc=DocumentHelper.parseText(result);
			//获取根节点
			Element root=doc.getRootElement();
			logger.info("-----------------核算科目查询接口-根节点："+root.getName());
			Iterator iterator=root.element("Body").element("QueryResponse").elementIterator("QueryResult");
			while(iterator.hasNext()) {
				Element element=(Element) iterator.next();
				String r=element.elementTextTrim("Result");
				//logger.info("----------------------核算科目查询接口-result："+result);
				if ("true".equals(r)) {
					Iterator recordsIterator=element.elementIterator("Records");
					while(recordsIterator.hasNext()) {
						Element recordsEle=(Element) recordsIterator.next();
						Iterator detail=recordsEle.elementIterator("ZWKMZD");
						while(detail.hasNext()) {
							Element detElement=(Element)detail.next();
							String ZWKMZD_ID=detElement.elementTextTrim("ZWKMZD_ID");//内码
							String ZWKMZD_TX=detElement.elementTextTrim("ZWKMZD_TX");//科目体系
							String ZWKMZD_KMBH=detElement.elementTextTrim("ZWKMZD_KMBH");//科目编号
							String ZWKMZD_KMMC=detElement.elementTextTrim("ZWKMZD_KMMC");//科目名称
							String ZWKMZD_SX=detElement.elementTextTrim("ZWKMZD_SX");//科目属性
							String ZWKMZD_JS=detElement.elementTextTrim("ZWKMZD_JS");//级数
							String ZWKMZD_MX=detElement.elementTextTrim("ZWKMZD_MX");//明细
							String ZWKMZD_FJM=detElement.elementTextTrim("ZWKMZD_FJM");//分级码
							String ZWKMZD_ZJM=detElement.elementTextTrim("ZWKMZD_ZJM");//助记码
							String ZWKMZD_HSSL=detElement.elementTextTrim("ZWKMZD_HSSL");//核算数量 0不核算 1核算
							String ZWKMZD_HSWB=detElement.elementTextTrim("ZWKMZD_HSWB");//核算外币‘0’:不核算‘1’:单一外币‘2’:所有币种
							String ZWKMZD_WBBH=detElement.elementTextTrim("ZWKMZD_WBBH");//外币编号
							String ZWKMZD_XZ=detElement.elementTextTrim("ZWKMZD_XZ");//科目性质‘0’:普通科目‘1’:借方栏目‘2’:贷方栏目
							String ZWKMZD_ZYGS=detElement.elementTextTrim("ZWKMZD_ZYGS");//账页格式‘0’:不设置‘1’:金额帐‘2’:数量金额帐‘3’:外币金额帐‘4’:数量外币金额帐
							String ZWKMZD_RJZ=detElement.elementTextTrim("ZWKMZD_RJZ");//是否日记账‘1’:是‘0’:否
							String ZWKMZD_YHZ=detElement.elementTextTrim("ZWKMZD_YHZ");//是否银行账‘1’:是‘0’:否
							String ZWKMZD_YEFX=detElement.elementTextTrim("ZWKMZD_YEFX");//余额方向‘1’:借方(Debit)‘2’:贷方(Credit)
							String ZWKMZD_XJKM=detElement.elementTextTrim("ZWKMZD_XJKM");//现金科目‘0’:其他‘1’:现金‘2’:银行存款‘3’:其它现金及现金等价物
							String ZWKMZD_XX01=detElement.elementTextTrim("ZWKMZD_XX01");//计量单位
							String ZWKMZD_XX02=detElement.elementTextTrim("ZWKMZD_XX02");//规格型号
							String ZWKMZD_XX03=detElement.elementTextTrim("ZWKMZD_XX03");//类型
							String ZWKMZD_YSPZ=detElement.elementTextTrim("ZWKMZD_YSPZ");//原始凭证
							String ZWKMZD_QMJP=detElement.elementTextTrim("ZWKMZD_QMJP");//期末结平
							String ZWKMZD_KMLX=detElement.elementTextTrim("ZWKMZD_KMLX");//科目类型‘1’:标准科目（建立科目体系时建立）‘2’:公司科目（建立核算单位时建立）
							String ZWKMZD_DWBH=detElement.elementTextTrim("ZWKMZD_DWBH");//单位编号
							String ZWKMZD_QXJS=detElement.elementTextTrim("ZWKMZD_QXJS");
							String ZWKMZD_QXBZ=detElement.elementTextTrim("ZWKMZD_QXBZ");//权限标志‘1’:是‘0’:否
							String ZWKMZD_TYBZ=detElement.elementTextTrim("ZWKMZD_TYBZ");//停用标志‘0’:启用‘1’:停用
							String ZWKMZD_ZJKM=detElement.elementTextTrim("ZWKMZD_ZJKM");//允许下级单位增加下级科目‘1’:是‘0’:否
							String ZWKMZD_YWMC=detElement.elementTextTrim("ZWKMZD_YWMC");//英文名称
							String ZWKMZD_ZJDW=detElement.elementTextTrim("ZWKMZD_ZJDW");//科目增加单位
							String ZWKMZD_SFYR=detElement.elementTextTrim("ZWKMZD_SFYR");//是否引入科目‘1’:是‘0’:否
							String ZWKMZD_KMQCCL=detElement.elementTextTrim("ZWKMZD_KMQCCL");//科目全称策略0:各级别科目名称连接1:一级科目名称＋当前科目名称2:上级科目全称＋当前科目名称3:手工输入
							String ZWKMZD_KMQC=detElement.elementTextTrim("ZWKMZD_KMQC");//科目全称 按照科目全称策略取值，多科目连接时，使用英文连字符“-”
							String ZWKMZD_KJLX=detElement.elementTextTrim("ZWKMZD_KJLX");//会计类型 ‘0’:财务会计‘1’:预算会计
							String CREATEUSER=detElement.elementTextTrim("CREATEUSER");//创建人
							String ctime=detElement.elementTextTrim("CREATETIME");//创建时间
							Date CREATETIME=getTimes(ctime);
							String LASTMODIFIEDUSER=detElement.elementTextTrim("LASTMODIFIEDUSER");//最后修改人
							String ltime=detElement.elementTextTrim("LASTMODIFIEDTIME");//最后修改时间
							Date LASTMODIFIEDTIME=getTimes(ltime);
							String ZWKMZD_YYDW=detElement.elementTextTrim("ZWKMZD_YYDW");//
							String ZWKMZD_NOTE=detElement.elementTextTrim("ZWKMZD_NOTE");//备注
							
							if (dingshi) {
								SubjectPO oldSubject=dealDataDao.findSubjectById(ZWKMZD_ID);
								if (oldSubject!=null) {
									oldSubject.setZWKMZD_TX(ZWKMZD_TX);
									oldSubject.setZWKMZD_KMBH(ZWKMZD_KMBH);
									oldSubject.setZWKMZD_KMMC(ZWKMZD_KMMC);
									oldSubject.setZWKMZD_SX(ZWKMZD_SX);
									oldSubject.setZWKMZD_JS(Integer.parseInt(ZWKMZD_JS));
									oldSubject.setZWKMZD_MX(ZWKMZD_MX);
									oldSubject.setZWKMZD_FJM(ZWKMZD_FJM);
									oldSubject.setZWKMZD_ZJM(ZWKMZD_ZJM);
									oldSubject.setZWKMZD_HSSL(ZWKMZD_HSSL);
									oldSubject.setZWKMZD_HSWB(ZWKMZD_HSWB);
									oldSubject.setZWKMZD_WBBH(ZWKMZD_WBBH);
									oldSubject.setZWKMZD_XZ(ZWKMZD_XZ);
									oldSubject.setZWKMZD_ZYGS(ZWKMZD_ZYGS);
									oldSubject.setZWKMZD_RJZ(ZWKMZD_RJZ);
									oldSubject.setZWKMZD_YHZ(ZWKMZD_YHZ);
									oldSubject.setZWKMZD_YEFX(ZWKMZD_YEFX);
									oldSubject.setZWKMZD_XJKM(ZWKMZD_XJKM);
									oldSubject.setZWKMZD_XX01(ZWKMZD_XX01);
									oldSubject.setZWKMZD_XX02(ZWKMZD_XX02);
									oldSubject.setZWKMZD_XX03(ZWKMZD_XX03);
									oldSubject.setZWKMZD_YSPZ(ZWKMZD_YSPZ);
									oldSubject.setZWKMZD_QMJP(ZWKMZD_QMJP);
									oldSubject.setZWKMZD_KMLX(ZWKMZD_KMLX);
									oldSubject.setZWKMZD_DWBH(ZWKMZD_DWBH);
									oldSubject.setZWKMZD_QXJS(ZWKMZD_QXJS);
									oldSubject.setZWKMZD_QXBZ(ZWKMZD_QXBZ);
									oldSubject.setZWKMZD_TYBZ(ZWKMZD_TYBZ);
									oldSubject.setZWKMZD_ZJKM(ZWKMZD_ZJKM);
									oldSubject.setZWKMZD_YWMC(ZWKMZD_YWMC);
									oldSubject.setZWKMZD_ZJDW(ZWKMZD_ZJDW);
									oldSubject.setZWKMZD_SFYR(ZWKMZD_SFYR);
									oldSubject.setZWKMZD_KMQCCL(ZWKMZD_KMQCCL);
									oldSubject.setZWKMZD_KMQC(ZWKMZD_KMQC);
									oldSubject.setZWKMZD_KJLX(ZWKMZD_KJLX);
									oldSubject.setCREATEUSER(CREATEUSER);
									oldSubject.setCREATETIME(CREATETIME);
									oldSubject.setLASTMODIFIEDUSER(LASTMODIFIEDUSER);
									oldSubject.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
									oldSubject.setZWKMZD_YYDW(ZWKMZD_YYDW);
									oldSubject.setZWKMZD_NOTE(ZWKMZD_NOTE);
									updateSubjectList.add(oldSubject);
									
									//查询部门对应科目表
//									if (ZWKMZD_ID.length()!=4) {
//										String yjbh=ZWKMZD_ID.substring(0, 4);
//										List<DeptToSubject> deptsubjectList=dealDataDao.findDeptSubjectList(yjbh);
//										
//										
//									}
//									List<DeptToSubject> deptsubjectList=dealDataDao.findDeptSubjectList(ZWKMZD_ID);
//									if (deptsubjectList!=null) {
//										SubjectPO yjPO=null;
//										if (ZWKMZD_KMBH.length()==4) {
//											yjPO=dealDataDao.findSubjectPo(ZWKMZD_KMBH);
//										}
//										List<DeptToSubject> updateList=new ArrayList<DeptToSubject>();
//										for(DeptToSubject deptToSubject:deptsubjectList) {
//											deptToSubject.setKMBH(ZWKMZD_KMBH);
//											deptToSubject.setKMMC(ZWKMZD_KMMC);
//											if (ZWKMZD_KMBH.length()==4) {
//												deptToSubject.setDYKMBH(yjPO.getZWKMZD_KMBH());
//												deptToSubject.setDYKMMC(ZWKMZD_KMMC);
//											}
//											deptToSubject.setKMQC(ZWKMZD_KMQC);
//											deptToSubject.setMX(ZWKMZD_MX);
//											deptToSubject.setKMLX(ZWKMZD_KMLX);
//											deptToSubject.setZWKMZD_TYBZ(ZWKMZD_TYBZ);
//											deptToSubject.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
//											updateList.add(deptToSubject);
//										}
//										dealDataDao.updateDeptSubjectList(updateList);
//									}
								}else {
									SubjectPO s=new SubjectPO();
									s.setIdIfNew();
									s.setZWKMZD_ID(ZWKMZD_ID);
									s.setZWKMZD_TX(ZWKMZD_TX);
									s.setZWKMZD_KMBH(ZWKMZD_KMBH);
									s.setZWKMZD_KMMC(ZWKMZD_KMMC);
									s.setZWKMZD_SX(ZWKMZD_SX);
									s.setZWKMZD_JS(Integer.parseInt(ZWKMZD_JS));
									s.setZWKMZD_MX(ZWKMZD_MX);
									s.setZWKMZD_FJM(ZWKMZD_FJM);
									s.setZWKMZD_ZJM(ZWKMZD_ZJM);
									s.setZWKMZD_HSSL(ZWKMZD_HSSL);
									s.setZWKMZD_HSWB(ZWKMZD_HSWB);
									s.setZWKMZD_WBBH(ZWKMZD_WBBH);
									s.setZWKMZD_XZ(ZWKMZD_XZ);
									s.setZWKMZD_ZYGS(ZWKMZD_ZYGS);
									s.setZWKMZD_RJZ(ZWKMZD_RJZ);
									s.setZWKMZD_YHZ(ZWKMZD_YHZ);
									s.setZWKMZD_YEFX(ZWKMZD_YEFX);
									s.setZWKMZD_XJKM(ZWKMZD_XJKM);
									s.setZWKMZD_XX01(ZWKMZD_XX01);
									s.setZWKMZD_XX02(ZWKMZD_XX02);
									s.setZWKMZD_XX03(ZWKMZD_XX03);
									s.setZWKMZD_YSPZ(ZWKMZD_YSPZ);
									s.setZWKMZD_QMJP(ZWKMZD_QMJP);
									s.setZWKMZD_KMLX(ZWKMZD_KMLX);
									s.setZWKMZD_DWBH(ZWKMZD_DWBH);
									s.setZWKMZD_QXJS(ZWKMZD_QXJS);
									s.setZWKMZD_QXBZ(ZWKMZD_QXBZ);
									s.setZWKMZD_TYBZ(ZWKMZD_TYBZ);
									s.setZWKMZD_ZJKM(ZWKMZD_ZJKM);
									s.setZWKMZD_YWMC(ZWKMZD_YWMC);
									s.setZWKMZD_ZJDW(ZWKMZD_ZJDW);
									s.setZWKMZD_SFYR(ZWKMZD_SFYR);
									s.setZWKMZD_KMQCCL(ZWKMZD_KMQCCL);
									s.setZWKMZD_KMQC(ZWKMZD_KMQC);
									s.setZWKMZD_KJLX(ZWKMZD_KJLX);
									s.setCREATEUSER(CREATEUSER);
									s.setCREATETIME(CREATETIME);
									s.setLASTMODIFIEDUSER(LASTMODIFIEDUSER);
									s.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
									s.setZWKMZD_YYDW(ZWKMZD_YYDW);
									s.setZWKMZD_NOTE(ZWKMZD_NOTE);
									subjectList.add(s);
									//添加对应科目字典数据
									List<DeptToSubject> deptsubjectList=new ArrayList<DeptToSubject>();
									DeptToSubject po=new DeptToSubject();
									po.setIdIfNew();
									po.setDWBH(null);
									po.setDWMC(null);
									po.setBMBH(null);
									po.setBMMC(null);
									po.setKMNM(ZWKMZD_ID);
									po.setKMID(String.valueOf(s.getId()));
									po.setKMBH(ZWKMZD_KMBH);
									po.setKMMC(ZWKMZD_KMMC);
									po.setSX(ZWKMZD_SX);
									SubjectPO yjpo=null;
									if (ZWKMZD_KMBH.length()!=4) {
										yjpo=dealDataDao.findSubjectPo(ZWKMZD_KMBH);
										po.setDYKMBH(yjpo.getZWKMZD_KMBH());
										po.setDYKMMC(yjpo.getZWKMZD_KMMC());
									}
									po.setKMQC(ZWKMZD_KMQC);
									po.setMX(ZWKMZD_MX);
									po.setXZ(ZWKMZD_XZ);
									po.setKMLX(ZWKMZD_KMLX);
									po.setZWKMZD_TYBZ(ZWKMZD_TYBZ);
									po.setCREATETIME(CREATETIME);
									po.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
									deptsubjectList.add(po);
									dealDataDao.saveDeptSubject(deptsubjectList);
								}
								
							}else {
								SubjectPO s=new SubjectPO();
								s.setIdIfNew();
								s.setZWKMZD_ID(ZWKMZD_ID);
								s.setZWKMZD_TX(ZWKMZD_TX);
								s.setZWKMZD_KMBH(ZWKMZD_KMBH);
								s.setZWKMZD_KMMC(ZWKMZD_KMMC);
								s.setZWKMZD_SX(ZWKMZD_SX);
								s.setZWKMZD_JS(Integer.parseInt(ZWKMZD_JS));
								s.setZWKMZD_MX(ZWKMZD_MX);
								s.setZWKMZD_FJM(ZWKMZD_FJM);
								s.setZWKMZD_ZJM(ZWKMZD_ZJM);
								s.setZWKMZD_HSSL(ZWKMZD_HSSL);
								s.setZWKMZD_HSWB(ZWKMZD_HSWB);
								s.setZWKMZD_WBBH(ZWKMZD_WBBH);
								s.setZWKMZD_XZ(ZWKMZD_XZ);
								s.setZWKMZD_ZYGS(ZWKMZD_ZYGS);
								s.setZWKMZD_RJZ(ZWKMZD_RJZ);
								s.setZWKMZD_YHZ(ZWKMZD_YHZ);
								s.setZWKMZD_YEFX(ZWKMZD_YEFX);
								s.setZWKMZD_XJKM(ZWKMZD_XJKM);
								s.setZWKMZD_XX01(ZWKMZD_XX01);
								s.setZWKMZD_XX02(ZWKMZD_XX02);
								s.setZWKMZD_XX03(ZWKMZD_XX03);
								s.setZWKMZD_YSPZ(ZWKMZD_YSPZ);
								s.setZWKMZD_QMJP(ZWKMZD_QMJP);
								s.setZWKMZD_KMLX(ZWKMZD_KMLX);
								s.setZWKMZD_DWBH(ZWKMZD_DWBH);
								s.setZWKMZD_QXJS(ZWKMZD_QXJS);
								s.setZWKMZD_QXBZ(ZWKMZD_QXBZ);
								s.setZWKMZD_TYBZ(ZWKMZD_TYBZ);
								s.setZWKMZD_ZJKM(ZWKMZD_ZJKM);
								s.setZWKMZD_YWMC(ZWKMZD_YWMC);
								s.setZWKMZD_ZJDW(ZWKMZD_ZJDW);
								s.setZWKMZD_SFYR(ZWKMZD_SFYR);
								s.setZWKMZD_KMQCCL(ZWKMZD_KMQCCL);
								s.setZWKMZD_KMQC(ZWKMZD_KMQC);
								s.setZWKMZD_KJLX(ZWKMZD_KJLX);
								s.setCREATEUSER(CREATEUSER);
								s.setCREATETIME(CREATETIME);
								s.setLASTMODIFIEDUSER(LASTMODIFIEDUSER);
								s.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
								s.setZWKMZD_YYDW(ZWKMZD_YYDW);
								s.setZWKMZD_NOTE(ZWKMZD_NOTE);
								subjectList.add(s);
							}
							
						}
					}
				}
			}
			logger.info("----------------------subjectList科目集合长度:"+subjectList.size());
			return subjectList;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	//处理往来单位接口返回数据
	public List<ContactUnit> getContactUnitList(String result,List<ContactUnit> contactUnitList,List<ContactUnit> updateContactUnitList,boolean dingshi){
		try {
			//字符串转xml
			Document doc=DocumentHelper.parseText(result);
			//获取根节点
			Element root=doc.getRootElement();
			logger.info("-----------------往来单位查询接口-根节点："+root.getName());
			Iterator iterator=root.element("Body").element("QueryResponse").elementIterator("QueryResult");
			while(iterator.hasNext()) {
				Element element=(Element) iterator.next();
				String r=element.elementTextTrim("Result");
				//logger.info("----------------------往来单位查询接口-result："+result);
				if ("true".equals(r)) {
					Iterator recordsIterator=element.elementIterator("Records");
					while(recordsIterator.hasNext()) {
						Element recordsEle=(Element) recordsIterator.next();
						Iterator detail=recordsEle.elementIterator("LSWLDW");
						while(detail.hasNext()) {
							Element detElement=(Element)detail.next();
							//循环接口返回数据（while/for），往contactUnitList赋值
							String LSWLDW_LSWLDWID=detElement.elementTextTrim("LSWLDW_LSWLDWID");//往来单位内码
							String LSWLDW_WLDWBH=detElement.elementTextTrim("LSWLDW_WLDWBH");//往来单位编号
							String ENTITYTYPE=detElement.elementTextTrim("ENTITYTYPE");//公私性质  0单位 1个人
							String LSWLDW_DWMC=detElement.elementTextTrim("LSWLDW_DWMC");//往来单位名称
							String LSWLDW_JC=detElement.elementTextTrim("LSWLDW_JC");//往来单位简称
							String LSWLDW_DQBH=detElement.elementTextTrim("LSWLDW_DQBH");//地区编号
							String LSWLDW_DWLB=detElement.elementTextTrim("LSWLDW_DWLB");//类别编号
							String LSWLDW_DWXZ=detElement.elementTextTrim("LSWLDW_DWXZ");//单位性质
							String LSWLDW_NBDW=detElement.elementTextTrim("LSWLDW_NBDW");//是否内部单位（单位类型）0：无 1：内部单位 2：关联单位
							String LSWLDW_NBDWBH=detElement.elementTextTrim("LSWLDW_NBDWBH");//内部单位编号
							String LSWLDW_BZ=detElement.elementTextTrim("LSWLDW_BZ");//币种
							String xyjb=detElement.elementTextTrim("LSWLDW_XYJB");
							Integer LSWLDW_XYJB=null;//信用级别
							if (!"".equals(xyjb)) {
								LSWLDW_XYJB=Integer.parseInt(xyjb);
							}
							String LSWLDW_ZYJB=detElement.elementTextTrim("LSWLDW_ZYJB");//重要级别
							String LSWLDW_KHH=detElement.elementTextTrim("LSWLDW_KHH");//开户行-开户行内码
							String LSWLDW_YHZH=detElement.elementTextTrim("LSWLDW_YHZH");//银行账号
							String LSWLDW_SH=detElement.elementTextTrim("LSWLDW_SH");//税号
							String LSWLDW_ADDR=detElement.elementTextTrim("LSWLDW_ADDR");//地址
							String LSWLDW_EMAL=detElement.elementTextTrim("LSWLDW_EMAL");//邮箱
							String LSWLDW_WEB=detElement.elementTextTrim("LSWLDW_WEB");//网址
							String LSWLDW_SSGS=detElement.elementTextTrim("LSWLDW_SSGS");//申请公司
							String LSWLDW_SSBM=detElement.elementTextTrim("LSWLDW_SSBM");//申请部门
							String LSWLDW_SSYWY=detElement.elementTextTrim("LSWLDW_SSYWY");//申请人
							String LSWLDW_QSRQ=detElement.elementTextTrim("LSWLDW_QSRQ");//申请日期
							String LSWLDW_ZZRQ=detElement.elementTextTrim("LSWLDW_ZZRQ");//终止日期
							String LSWLDW_CJDW=detElement.elementTextTrim("LSWLDW_CJDW");//创建单位
							String LSWLDW_CREATOR=detElement.elementTextTrim("LSWLDW_CREATOR");//创建人
							BigDecimal LSWLDW_XYED=null;//信用额度
							String XYED=detElement.elementTextTrim("LSWLDW_XYED");
							if (!"".equals(XYED)) {
								LSWLDW_XYED=new BigDecimal(XYED);
							}
							
							String LSWLDW_LXR=detElement.elementTextTrim("LSWLDW_LXR");//联系人
							String LSWLDW_DWBH=detElement.elementTextTrim("LSWLDW_DWBH");//单位编号
							String LSWLDW_PHONE=detElement.elementTextTrim("LSWLDW_PHONE");//联系电话
							String LSWLDW_FAX=detElement.elementTextTrim("LSWLDW_FAX");//传真
							String LSWLDW_TYBZ=detElement.elementTextTrim("LSWLDW_TYBZ");//停用标志 0启用 1停用
							String LSWLDW_TYND=detElement.elementTextTrim("LSWLDW_TYND");//停用年度
							String TOPPARTNER=detElement.elementTextTrim("TOPPARTNER");//上级单位编号
							String PATH=detElement.elementTextTrim("PATH");//分级路径
							Integer LAYER=null;
							String js=detElement.elementTextTrim("LAYER");//级数
							if (!"".equals(js)) {
								LAYER=Integer.parseInt(js);//级数
							}
							String ISDETAIL=detElement.elementTextTrim("ISDETAIL");//明细
							String HELPTAG=detElement.elementTextTrim("HELPTAG");//助记码
							String FOREIGNNAME=detElement.elementTextTrim("FOREIGNNAME");//外文名称
							String OFREGION=detElement.elementTextTrim("OFREGION");//行政区划编号
							String ZIPCODE=detElement.elementTextTrim("ZIPCODE");//邮政编码
							String AUDITFLOWCHARID=detElement.elementTextTrim("AUDITFLOWCHARID");//审核流程图号
							String OFTRADE=detElement.elementTextTrim("OFTRADE");//所属行业
							String OWNERTYPE=detElement.elementTextTrim("OWNERTYPE");//所有者类型
							String LEGALBODY=detElement.elementTextTrim("LEGALBODY");//法人代表
							BigDecimal REGISTERFUND=null;//注册资金
							String zczj=detElement.elementTextTrim("REGISTERFUND");
							if (!"".equals(zczj)) {
								REGISTERFUND=new BigDecimal(zczj);
							}
							String BRIEF=detElement.elementTextTrim("BRIEF");//简介
							String NOTE=detElement.elementTextTrim("NOTE");//备注
							String LASTEDITDATE=detElement.elementTextTrim("LASTEDITDATE");//最后修改日期
							String PLANTID=detElement.elementTextTrim("PLANTID");//内部工厂标识符
							String TAXPAYERTYPE=detElement.elementTextTrim("TAXPAYERTYPE");//纳税类型
							BigDecimal TAXRATE=null;//征收率
							String zsl=detElement.elementTextTrim("TAXRATE");
							if (!"".equals(zsl)) {
								TAXRATE=new BigDecimal(zsl);
							}
							String BESTSHIPPOINT=detElement.elementTextTrim("BESTSHIPPOINT");//最佳发货地id
							String SHIPTOPOINT=detElement.elementTextTrim("SHIPTOPOINT");//送达站id
							String ADSCNATION=detElement.elementTextTrim("ADSCNATION");//国家
							String LSWLDW_CERTIFICATE=detElement.elementTextTrim("LSWLDW_CERTIFICATE");//组织机构代码
							String createT=detElement.elementTextTrim("CREATEDTIME");
							Date CREATEDTIME=getTimes(createT);//创建时间
							String lastT=detElement.elementTextTrim("LASTMODIFIEDTIME");
							Date LASTMODIFIEDTIME=getTimes(lastT);//最后修改时间
							String CREATOR=detElement.elementTextTrim("CREATOR");//创建人
							String LASTMODIFIER=detElement.elementTextTrim("LASTMODIFIER");//最后修改人
							String DJZT=detElement.elementTextTrim("DJZT");//单据状态
							String LCSL=detElement.elementTextTrim("LCSL");//审批流程实例
							if (dingshi) {
								ContactUnit oldContactUnit=dealDataDao.findContactUnitByNm(LSWLDW_LSWLDWID);
								if (oldContactUnit!=null) {
									oldContactUnit.setLSWLDW_WLDWBH(LSWLDW_WLDWBH);
									oldContactUnit.setENTITYTYPE(ENTITYTYPE);
									oldContactUnit.setLSWLDW_DWMC(LSWLDW_DWMC);
									oldContactUnit.setLSWLDW_JC(LSWLDW_JC);
									oldContactUnit.setLSWLDW_DQBH(LSWLDW_DQBH);
									oldContactUnit.setLSWLDW_DWLB(LSWLDW_DWLB);
									oldContactUnit.setLSWLDW_DWXZ(LSWLDW_DWXZ);
									oldContactUnit.setLSWLDW_NBDW(LSWLDW_NBDW);
									oldContactUnit.setLSWLDW_NBDWBH(LSWLDW_NBDWBH);
									oldContactUnit.setLSWLDW_BZ(LSWLDW_BZ);
									oldContactUnit.setLSWLDW_XYJB(LSWLDW_XYJB);
									oldContactUnit.setLSWLDW_ZYJB(LSWLDW_ZYJB);
									oldContactUnit.setLSWLDW_KHH(LSWLDW_KHH);
									oldContactUnit.setLSWLDW_YHZH(LSWLDW_YHZH);
									oldContactUnit.setLSWLDW_SH(LSWLDW_SH);
									oldContactUnit.setLSWLDW_ADDR(LSWLDW_ADDR);
									oldContactUnit.setLSWLDW_EMAL(LSWLDW_EMAL);
									oldContactUnit.setLSWLDW_WEB(LSWLDW_WEB);
									oldContactUnit.setLSWLDW_SSGS(LSWLDW_SSGS);
									oldContactUnit.setLSWLDW_SSBM(LSWLDW_SSBM);
									oldContactUnit.setLSWLDW_SSYWY(LSWLDW_SSYWY);
									oldContactUnit.setLSWLDW_QSRQ(LSWLDW_QSRQ);
									oldContactUnit.setLSWLDW_ZZRQ(LSWLDW_ZZRQ);
									oldContactUnit.setLSWLDW_CJDW(LSWLDW_CJDW);
									oldContactUnit.setLSWLDW_CREATOR(LSWLDW_CREATOR);
									oldContactUnit.setLSWLDW_XYED(LSWLDW_XYED);
									oldContactUnit.setLSWLDW_LXR(LSWLDW_LXR);
									oldContactUnit.setLSWLDW_DWBH(LSWLDW_DWBH);
									oldContactUnit.setLSWLDW_PHONE(LSWLDW_PHONE);
									oldContactUnit.setLSWLDW_FAX(LSWLDW_FAX);
									oldContactUnit.setLSWLDW_TYBZ(LSWLDW_TYBZ);
									oldContactUnit.setLSWLDW_TYND(LSWLDW_TYND);
									oldContactUnit.setTOPPARTNER(TOPPARTNER);
									oldContactUnit.setPATH(PATH);
									oldContactUnit.setLAYER(LAYER);
									oldContactUnit.setISDETAIL(ISDETAIL);
									oldContactUnit.setHELPTAG(HELPTAG);
									oldContactUnit.setFOREIGNNAME(FOREIGNNAME);
									oldContactUnit.setOFREGION(OFREGION);
									oldContactUnit.setZIPCODE(ZIPCODE);
									oldContactUnit.setAUDITFLOWCHARID(AUDITFLOWCHARID);
									oldContactUnit.setOFTRADE(OFTRADE);
									oldContactUnit.setOWNERTYPE(OWNERTYPE);
									oldContactUnit.setLEGALBODY(LEGALBODY);
									oldContactUnit.setREGISTERFUND(REGISTERFUND);
									oldContactUnit.setBRIEF(BRIEF);
									oldContactUnit.setNOTE(NOTE);
									oldContactUnit.setLASTEDITDATE(LASTEDITDATE);
									oldContactUnit.setPLANTID(PLANTID);
									oldContactUnit.setTAXPAYERTYPE(TAXPAYERTYPE);
									oldContactUnit.setTAXRATE(TAXRATE);
									oldContactUnit.setBESTSHIPPOINT(BESTSHIPPOINT);
									oldContactUnit.setSHIPTOPOINT(SHIPTOPOINT);
									oldContactUnit.setADSCNATION(ADSCNATION);
									oldContactUnit.setLSWLDW_CERTIFICATE(LSWLDW_CERTIFICATE);
									oldContactUnit.setCREATEDTIME(CREATEDTIME);
									oldContactUnit.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
									oldContactUnit.setCREATOR(CREATOR);
									oldContactUnit.setLASTMODIFIER(LASTMODIFIER);
									oldContactUnit.setDJZT(DJZT);
									oldContactUnit.setLCSL(LCSL);
									updateContactUnitList.add(oldContactUnit);
								}else {
									ContactUnit unit=new ContactUnit();
									unit.setIdIfNew();
									unit.setLSWLDW_LSWLDWID(LSWLDW_LSWLDWID);
									unit.setLSWLDW_WLDWBH(LSWLDW_WLDWBH);
									unit.setENTITYTYPE(ENTITYTYPE);
									unit.setLSWLDW_DWMC(LSWLDW_DWMC);
									unit.setLSWLDW_JC(LSWLDW_JC);
									unit.setLSWLDW_DQBH(LSWLDW_DQBH);
									unit.setLSWLDW_DWLB(LSWLDW_DWLB);
									unit.setLSWLDW_DWXZ(LSWLDW_DWXZ);
									unit.setLSWLDW_NBDW(LSWLDW_NBDW);
									unit.setLSWLDW_NBDWBH(LSWLDW_NBDWBH);
									unit.setLSWLDW_BZ(LSWLDW_BZ);
									unit.setLSWLDW_XYJB(LSWLDW_XYJB);
									unit.setLSWLDW_ZYJB(LSWLDW_ZYJB);
									unit.setLSWLDW_KHH(LSWLDW_KHH);
									unit.setLSWLDW_YHZH(LSWLDW_YHZH);
									unit.setLSWLDW_SH(LSWLDW_SH);
									unit.setLSWLDW_ADDR(LSWLDW_ADDR);
									unit.setLSWLDW_EMAL(LSWLDW_EMAL);
									unit.setLSWLDW_WEB(LSWLDW_WEB);
									unit.setLSWLDW_SSGS(LSWLDW_SSGS);
									unit.setLSWLDW_SSBM(LSWLDW_SSBM);
									unit.setLSWLDW_SSYWY(LSWLDW_SSYWY);
									unit.setLSWLDW_QSRQ(LSWLDW_QSRQ);
									unit.setLSWLDW_ZZRQ(LSWLDW_ZZRQ);
									unit.setLSWLDW_CJDW(LSWLDW_CJDW);
									unit.setLSWLDW_CREATOR(LSWLDW_CREATOR);
									unit.setLSWLDW_XYED(LSWLDW_XYED);
									unit.setLSWLDW_LXR(LSWLDW_LXR);
									unit.setLSWLDW_DWBH(LSWLDW_DWBH);
									unit.setLSWLDW_PHONE(LSWLDW_PHONE);
									unit.setLSWLDW_FAX(LSWLDW_FAX);
									unit.setLSWLDW_TYBZ(LSWLDW_TYBZ);
									unit.setLSWLDW_TYND(LSWLDW_TYND);
									unit.setTOPPARTNER(TOPPARTNER);
									unit.setPATH(PATH);
									unit.setLAYER(LAYER);
									unit.setISDETAIL(ISDETAIL);
									unit.setHELPTAG(HELPTAG);
									unit.setFOREIGNNAME(FOREIGNNAME);
									unit.setOFREGION(OFREGION);
									unit.setZIPCODE(ZIPCODE);
									unit.setAUDITFLOWCHARID(AUDITFLOWCHARID);
									unit.setOFTRADE(OFTRADE);
									unit.setOWNERTYPE(OWNERTYPE);
									unit.setLEGALBODY(LEGALBODY);
									unit.setREGISTERFUND(REGISTERFUND);
									unit.setBRIEF(BRIEF);
									unit.setNOTE(NOTE);
									unit.setLASTEDITDATE(LASTEDITDATE);
									unit.setPLANTID(PLANTID);
									unit.setTAXPAYERTYPE(TAXPAYERTYPE);
									unit.setTAXRATE(TAXRATE);
									unit.setBESTSHIPPOINT(BESTSHIPPOINT);
									unit.setSHIPTOPOINT(SHIPTOPOINT);
									unit.setADSCNATION(ADSCNATION);
									unit.setLSWLDW_CERTIFICATE(LSWLDW_CERTIFICATE);
									unit.setCREATEDTIME(CREATEDTIME);
									unit.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
									unit.setCREATOR(CREATOR);
									unit.setLASTMODIFIER(LASTMODIFIER);
									unit.setDJZT(DJZT);
									unit.setLCSL(LCSL);
									contactUnitList.add(unit);
								}
								
							}else {
								ContactUnit unit=new ContactUnit();
								unit.setIdIfNew();
								unit.setLSWLDW_LSWLDWID(LSWLDW_LSWLDWID);
								unit.setLSWLDW_WLDWBH(LSWLDW_WLDWBH);
								unit.setENTITYTYPE(ENTITYTYPE);
								unit.setLSWLDW_DWMC(LSWLDW_DWMC);
								unit.setLSWLDW_JC(LSWLDW_JC);
								unit.setLSWLDW_DQBH(LSWLDW_DQBH);
								unit.setLSWLDW_DWLB(LSWLDW_DWLB);
								unit.setLSWLDW_DWXZ(LSWLDW_DWXZ);
								unit.setLSWLDW_NBDW(LSWLDW_NBDW);
								unit.setLSWLDW_NBDWBH(LSWLDW_NBDWBH);
								unit.setLSWLDW_BZ(LSWLDW_BZ);
								unit.setLSWLDW_XYJB(LSWLDW_XYJB);
								unit.setLSWLDW_ZYJB(LSWLDW_ZYJB);
								unit.setLSWLDW_KHH(LSWLDW_KHH);
								unit.setLSWLDW_YHZH(LSWLDW_YHZH);
								unit.setLSWLDW_SH(LSWLDW_SH);
								unit.setLSWLDW_ADDR(LSWLDW_ADDR);
								unit.setLSWLDW_EMAL(LSWLDW_EMAL);
								unit.setLSWLDW_WEB(LSWLDW_WEB);
								unit.setLSWLDW_SSGS(LSWLDW_SSGS);
								unit.setLSWLDW_SSBM(LSWLDW_SSBM);
								unit.setLSWLDW_SSYWY(LSWLDW_SSYWY);
								unit.setLSWLDW_QSRQ(LSWLDW_QSRQ);
								unit.setLSWLDW_ZZRQ(LSWLDW_ZZRQ);
								unit.setLSWLDW_CJDW(LSWLDW_CJDW);
								unit.setLSWLDW_CREATOR(LSWLDW_CREATOR);
								unit.setLSWLDW_XYED(LSWLDW_XYED);
								unit.setLSWLDW_LXR(LSWLDW_LXR);
								unit.setLSWLDW_DWBH(LSWLDW_DWBH);
								unit.setLSWLDW_PHONE(LSWLDW_PHONE);
								unit.setLSWLDW_FAX(LSWLDW_FAX);
								unit.setLSWLDW_TYBZ(LSWLDW_TYBZ);
								unit.setLSWLDW_TYND(LSWLDW_TYND);
								unit.setTOPPARTNER(TOPPARTNER);
								unit.setPATH(PATH);
								unit.setLAYER(LAYER);
								unit.setISDETAIL(ISDETAIL);
								unit.setHELPTAG(HELPTAG);
								unit.setFOREIGNNAME(FOREIGNNAME);
								unit.setOFREGION(OFREGION);
								unit.setZIPCODE(ZIPCODE);
								unit.setAUDITFLOWCHARID(AUDITFLOWCHARID);
								unit.setOFTRADE(OFTRADE);
								unit.setOWNERTYPE(OWNERTYPE);
								unit.setLEGALBODY(LEGALBODY);
								unit.setREGISTERFUND(REGISTERFUND);
								unit.setBRIEF(BRIEF);
								unit.setNOTE(NOTE);
								unit.setLASTEDITDATE(LASTEDITDATE);
								unit.setPLANTID(PLANTID);
								unit.setTAXPAYERTYPE(TAXPAYERTYPE);
								unit.setTAXRATE(TAXRATE);
								unit.setBESTSHIPPOINT(BESTSHIPPOINT);
								unit.setSHIPTOPOINT(SHIPTOPOINT);
								unit.setADSCNATION(ADSCNATION);
								unit.setLSWLDW_CERTIFICATE(LSWLDW_CERTIFICATE);
								unit.setCREATEDTIME(CREATEDTIME);
								unit.setLASTMODIFIEDTIME(LASTMODIFIEDTIME);
								unit.setCREATOR(CREATOR);
								unit.setLASTMODIFIER(LASTMODIFIER);
								unit.setDJZT(DJZT);
								unit.setLCSL(LCSL);
								contactUnitList.add(unit);
							}
							
						}
					}
				}
			}
			
			logger.info("---------------------contactUnitList往来单位集合长度:"+contactUnitList.size());
			return contactUnitList;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	//处理计数接口返回的结果
	public int getCount(String res) {
		try {
			int count=0;
			//字符串转xml
			Document doc=DocumentHelper.parseText(res);
			//获取根节点
			Element root=doc.getRootElement();
			logger.info("-----------------计数服务接口-根节点："+root.getName());
			Iterator iterator=root.element("Body").element("CountResponse").elementIterator("CountResult");
			while(iterator.hasNext()) {
				Element element=(Element) iterator.next();
				String result=element.elementTextTrim("Result");
				logger.info("----------------------计数服务接口-result："+result);
				if ("true".equals(result)) {
					String num=element.elementTextTrim("Count");
					logger.info("----------------------计数服务接口-count："+num);
					count=Integer.parseInt(num);
				}
			}
			return count;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}
	//格林威治时间转字符串类型
	public String getTimeStr(String str) throws ParseException{
		SimpleDateFormat ssss = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        TimeZone tz = TimeZone.getTimeZone("Asia/Beijing");
        ssss.setTimeZone(tz);
        Date date = ssss.parse(str);
        String string = date.toString();
        //logger.info("-------String:"+string);
        SimpleDateFormat r = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String gsh=r.format(date);
		return gsh;
	}
	//格林威治时间转Date类型
	public Date getTimes(String str) throws ParseException {
		SimpleDateFormat ssss = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        TimeZone tz = TimeZone.getTimeZone("Asia/Beijing");
        ssss.setTimeZone(tz);
        Date date = ssss.parse(str);
        String string = date.toString();
        //logger.info("-------String:"+string);
        SimpleDateFormat r = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String gsh=r.format(date);
		Date newD=r.parse(gsh);
		return newD;
	}
}
